package com.business.system.util;

import java.text.DecimalFormat;

/**
 * @author: xudy
 * @date: 2018/04/25 13:38
 * @description:返利计算公式
 */
public class BackFeeUtil {

    public static double calcBackFee(double totalFee,double rate,double realFee){
        if(rate==0 || Double.isNaN(totalFee) || Double.isNaN(realFee)){
            return 0;
        }
        //返利计算公式backFee = v-p/(1-avg(rate))
        //其中v:实际金额 ,p:代理费用  rate:代理多个品牌的佣金率的平均值
        DecimalFormat format = new DecimalFormat("#.00");
        double backFee = 0;
        backFee = realFee-totalFee/rate;
        return Double.parseDouble(format.format(backFee));
    }
}